/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ac.pbp.model;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/**
 *
 * @author Kim
 */
@Entity
@Table(name = "pengarang")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Pengarang implements Serializable {

    @Id
    @Column(name = "kode_pengarang")
    private String kodePengarang;
    
    @Column(name = "nama_pengarang")
    private String namaPengarang;
    
    @Column(name = "gender_pengarang")
    private String genderPengarang;
    
    @Column(name = "tempat_lahir")
    private String tempatLahir;
    
    @Column(name = "deskripsi_pengarang")
    private String deskripsiPengarang;

    @Column(name = "picture")
    private String picture;
    
    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    public String getDeskripsiPengarang() {
        return deskripsiPengarang;
    }

    public void setDeskripsiPengarang(String deskripsiPengarang) {
        this.deskripsiPengarang = deskripsiPengarang;
    }
    
    @Column(name = "tanggal_ultah")
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date tanggalUltah;
    
    @OneToMany(mappedBy="pengarang",fetch=FetchType.LAZY,cascade=CascadeType.ALL)
    @LazyCollection(LazyCollectionOption.EXTRA)
    @Fetch(FetchMode.SELECT)
    @OrderBy("kodeBuku ASC")
    private Set<Buku> bukuList = new HashSet<Buku>();
    
    public String getKodePengarang() {
        return kodePengarang;
    }

    public String getNamaPengarang() {
        return namaPengarang;
    }

    public String getGenderPengarang() {
        return genderPengarang;
    }

    public String getTempatLahir() {
        return tempatLahir;
    }

    public Date getTanggalUltah() {
        return tanggalUltah;
    }

    public void setKodePengarang(String kodePengarang) {
        this.kodePengarang = kodePengarang;
    }

    public void setNamaPengarang(String namaPengarang) {
        this.namaPengarang = namaPengarang;
    }

    public void setGenderPengarang(String genderPengarang) {
        this.genderPengarang = genderPengarang;
    }

    public void setTempatLahir(String tempatLahir) {
        this.tempatLahir = tempatLahir;
    }

    public void setTanggalUltah(Date tanggalUltah) {
        this.tanggalUltah = tanggalUltah;
    }

    public Set<Buku> getBukuList() {
        return bukuList;
    }

    public void setBukuList(Set<Buku> bukuList) {
        this.bukuList = bukuList;
    }
}
